package com.qf.votedemo.task;

import com.qf.votedemo.contestant.service.IContestantphoneService;
import com.qf.votedemo.webSocket.WebSocketServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;

/**
 * @author 刘欣
 * @createTime 2023/2/25 14:52
 * @description 页面每3秒钟需要接收一次服务器端推送的参数投票总人数
 */
@Component
@Slf4j
public class ShowTicket {

    @Autowired
    private IContestantphoneService contestantphoneService;


//    @Scheduled(cron = "0/3 * * * * ?")
    public void showTotal() throws IOException {
        Integer total = contestantphoneService.getTotal();
        log.debug("总人数" + total);
        WebSocketServer.sengMsg(total + "");
    }
}
